import random
import json

random.seed(404)
train_text = 'bladder2114_train.json'
val_text = 'bladder2114_val.json'
test_text = 'bladder2114_test.json'
train_list, val_list, test_list = [], [], []
with open('bladder2114.json', 'r', encoding='utf-8') as f:
    data = json.load(f)
for info in data:
    r = random.randint(1, 10)
    if r < 9 or (info['imageId'] in ["0_366261_00010_00004_873_W1021L446.jpg", "3_378122_00008_00003_796_W1175L554.jpg"]):
        train_list.append(info)
    elif r < 10:
        val_list.append(info)
    else:
        test_list.append(info)
with open(train_text, "w") as json_file:
    json.dump(train_list, json_file)
with open(val_text, "w") as json_file:
    json.dump(val_list, json_file)
with open(test_text, "w") as json_file:
    json.dump(test_list, json_file)


